namespace THANHTUNGO.Portal.Components.Helpers
{
    public class FileHelper
    {
        public static string GetFileSizeString(object filesize)
        {
            double size = double.Parse(filesize.ToString());
            if (size < 1024)
                return size.ToString("N2") + " bytes";

            if (size < 1048576)
                return (size/1024).ToString("N2") + " KB";

            if (size < 1073741824)
                return (size/1048576).ToString("N2") + " MB";

            return (size/1073741824).ToString("N2") + " GB";
        }
    }
}